package com.thejavacode.quartz;

import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.QuartzJobBean;

public class SpringDummyJob extends QuartzJobBean {

	  private ApplicationContext ctx;
	  
	  public void setApplicationContext(ApplicationContext applicationContext) {
	    this.ctx = applicationContext;
	  }

	  protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
		  SpringQuartzJob sqj = (SpringQuartzJob)ctx.getBean("springQuartzJob");
		  try {
			sqj.execute();
		} catch (Exception e) {
			throw new JobExecutionException("ERROR EN LA EJECUCION DE LA TAREA QUARTZ: \n",e, false);
		}
	  }
	}
